{% extends 'base.html' %} {% load staticfiles %} {% block title %}用户信息{% endblock %} {% block css %}

<!-- Theme style -->
<link rel="stylesheet" href="{% static 'dist/css/AdminLTE.min.css' %}">
<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="{% static 'dist/css/skins/_all-skins.min.css' %}"> {% endblock %} {% block content %}

<!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
        用户信息
  </h1>
  <ol class="breadcrumb">
    <li><a href={% url 'dashboard' %}><i class="fa fa-dashboard"></i> 主页</a></li>
    <li>用户管理</li>
    <li class="active">用户详细信息</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">

  <!-- Default box -->
  <div class="box">
    <div class="box-body">
      <div class="nav-tabs-custom">
        <div class="tab-content">
              <div class="row">
                <div class="col-xs-2 text-right">用户名:</div>
                <div class="col-xs-4">{{ user.username }}</div>
                <div class="col-xs-2 text-right">超级用户:</div>
                <div class="col-xs-4">{{ user.is_superuser }}</div>
              </div>
              <br>
              <div class="row">
                <div class="col-xs-2 text-right">后台权限:</div>
                <div class="col-xs-4">{{ user.is_staff }}</div>
                <div class="col-xs-2 text-right">邮箱:</div>
                <div class="col-xs-4">{{ user.email }} &nbsp&nbsp<button class="btn btn-default btn-sm" data-toggle="modal" data-target="#maileditModal">修改邮箱</button></div>
              </div>
              <br>
              <div class="row">
                <div class="col-xs-2 text-right">创建时间:</div>
                <div class="col-xs-4">{{ user.date_joined|date:"Y-m-d  H:i:s" }}</div>
                <div class="col-xs-2 text-right">状态:</div>
                <div class="col-xs-4">{{ user.is_active }}</a></div>
              </div>
              <br>
              <div class="row">
                <div class="col-xs-2 text-right">最后登录:</div>
                <div class="col-xs-4">{{ user.last_login|date:"Y-m-d  H:i:s" }}</a></div>
              </div>
              <br>
              <div class="row">
                <div class="col-xs-2 text-right">备注:</div>
                <div class="col-xs-4">{{ user.name }}</div>
              </div>
              <br>          
            <p style=" margin:0 auto; text-align:center;">
            <button class="btn btn-default " align="center" data-toggle="modal" data-target="#userinfoeditModal">修改密码</button> 
            </p>
            <br>
          </div>
        </div>
      </div>
    </div>
    <form class="form-horizontal content_size" action="{% url 'userinfo' %}" method="post" onsubmit="return checkPassword()">
  {% csrf_token %}
  <div class="modal fade" id='userinfoeditModal' tabindex="-1" role="dialog" aria-labelledby='myModelLabel' aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title">用户信息修改</h4>
        </div>
        <div class="modal-body">
          <form class="form-horizontal" role="form">
          <div class="form-group">
            <label for="modify" class="col-sm-3 control-label">旧密码:</label>
            <div class="col-sm-6">
            <input type="password" class="form-control" name='old_password'>
            </div>
          </div>
          <div class="form-group">
            <label for="modify" class="col-sm-3 control-label">新密码:</label>
            <div class="col-sm-6">
            <input type="password" id="password" class="form-control" name='password'>
            </div>
          </div>
          <div class="form-group">
            <label for="modify" class="col-sm-3 control-label">再次输入新密码:</label>
            <div class="col-sm-6">
            <input type="password" id="re_password" class="form-control" name='re_password'>
            </div>
          </div>
        </form>
        </div>
        <div class="modal-footer">
          <button type="submit" name="submit" value="changepwd" class="btn btn-primary">确认</button>
          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        </div>
      </div>
    </div>
  </div>
</form>

    <form class="form-horizontal content_size" action="{% url 'userinfo' %}" method="post">
  {% csrf_token %}
  <div class="modal fade" id='maileditModal' tabindex="-1" role="dialog" aria-labelledby='myModelLabel' aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title">用户邮箱修改</h4>
        </div>
        <div class="modal-body">
          <form class="form-horizontal" role="form">
          <div class="form-group">
            <label for="modify" class="col-sm-3 control-label">邮箱:</label>
            <div class="col-sm-6">
            <input type="email" class="form-control" name='email'>
            </div>
          </div>
        </form>
        </div>
        <div class="modal-footer">
          <button type="submit" name="submit" value="changemail" class="btn btn-primary">确认</button>
          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        </div>
      </div>
    </div>
  </div>
</form>

    <!-- /.box-body -->
    <div class="box-footer">
      <i class="fa fa-angle-double-left"></i>&nbsp;&nbsp;<a href="{% url 'index' %}"><strong>返回资产列表页</strong></a>
    </div>
    <!-- /.box-footer-->
  </div>
  <!-- /.box -->
</section>
<!-- /.content -->
{% endblock %}
{% block page-script %}
<script>
 function checkPassword() {
        var password = document.getElementById('password');
        var confirm= document.getElementById('re_password');
        if(password.value.length < 6 || password.value.length > 20){
             alert('密码必须是6-20位');
             return false;
         }

       if(password.value != confirm.value){
             alert('密码不一致');
             return false;
         }
}
</script>
{% endblock %}
